/**
 * 定义页面对应的后台处理类完整路径。
 */
var clsUrl = basePath + 'JarpListener?className=cn.com.zsc.income.IncomeManage';

/**
 * 暂无图片
 */
var nonImage = basePath + 'images/zanwu.jpg';

/**
 * 导游星级
 */
var starLevel;

/**
 * 观光点个数 
 */
var attractionsNums;

/**
 * 带团类型
 */
var incomeType;

/**
 * 当前导游编号
 */
var curGuideID;

Ext.onReady(function() {
	Ext.QuickTips.init();
	
	/**
	 * 需无发票数据源
	 */
	var invoiceStore_fit = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '12'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
								      {name : 'CL_CODE'}, 
								      {name : 'CL_NAME'}
								     ]
						}),
				autoLoad : true,
				listeners:{'load':function() {
						Ext.getCmp("invoice_fit").setValue(Ext.getCmp("invoice_fit").getValue());
					}
				}
			});

	/**
	 * 需无发票控件
	 */
	var invoice_fit = new Ext.form.ComboBox({
				fieldLabel : '需无发票',
				id : 'invoice_fit',
				width : 85,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				emptyText : '请选择',
				store : invoiceStore_fit,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				selectOnFocus : true,
				
				listeners:{
					'render':function() {
						this.setValue(41);
						Ext.getCmp("invoice_fit").getStore().reload();
					}
				}
			});
			
	/**
	 * 需无发票数据源
	 */
	var invoiceStore_term = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '12'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
								      {name : 'CL_CODE'}, 
								      {name : 'CL_NAME'}
								     ]
						}),
				autoLoad : true,
				listeners:{'load':function() {
						Ext.getCmp("invoice_term").setValue(Ext.getCmp("invoice_term").getValue());
					}
				}
			});

	/**
	 * 需无发票控件
	 */
	var invoice_term = new Ext.form.ComboBox({
				fieldLabel : '需无发票',
				id : 'invoice_term',
				width : 85,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				emptyText : '请选择',
				store : invoiceStore_term,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				selectOnFocus : true,
				
				listeners:{
					'render':function() {
						this.setValue(41);
						Ext.getCmp("invoice_term").getStore().reload();
					}
				}
			});
			
	/**
	 * 需无发票数据源
	 */
	var invoiceStore_custReceive = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '12'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
								      {name : 'CL_CODE'}, 
								      {name : 'CL_NAME'}
								     ]
						}),
				autoLoad : true,
				listeners:{'load':function() {
						Ext.getCmp("invoice_custReceive").setValue(Ext.getCmp("invoice_custReceive").getValue());
					}
				}
			});

	/**
	 * 需无发票控件
	 */
	var invoice_custReceive = new Ext.form.ComboBox({
				fieldLabel : '需无发票',
				id : 'invoice_custReceive',
				width : 85,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				emptyText : '请选择',
				store : invoiceStore_custReceive,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				selectOnFocus : true,
				
				listeners:{
					'render':function() {
						this.setValue(41);
						Ext.getCmp("invoice_custReceive").getStore().reload();
					}
				}
			});
	
	/**
	 * 需无发票数据源
	 */
	var invoiceStore_govtReceive = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '12'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
								      {name : 'CL_CODE'}, 
								      {name : 'CL_NAME'}
								     ]
						}),
				autoLoad : true,
				listeners:{'load':function() {
						Ext.getCmp("invoice_govtReceive").setValue(Ext.getCmp("invoice_govtReceive").getValue());
					}
				}
			});

	/**
	 * 需无发票控件
	 */
	var invoice_govtReceive = new Ext.form.ComboBox({
				fieldLabel : '需无发票',
				id : 'invoice_govtReceive',
				width : 85,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				emptyText : '请选择',
				store : invoiceStore_govtReceive,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				selectOnFocus : true,
				
				listeners:{
					'render':function() {
						this.setValue(41);
						Ext.getCmp("invoice_govtReceive").getStore().reload();
					}
				}
			});
			
	/**
	 * 需无发票数据源
	 */
	var invoiceStore_cooperateReceive = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '12'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
								      {name : 'CL_CODE'}, 
								      {name : 'CL_NAME'}
								     ]
						}),
				autoLoad : true,
				listeners:{'load':function() {
						Ext.getCmp("invoice_cooperateReceive").setValue(Ext.getCmp("invoice_cooperateReceive").getValue());
					}
				}
			});

	/**
	 * 需无发票控件
	 */
	var invoice_cooperateReceive = new Ext.form.ComboBox({
				fieldLabel : '需无发票',
				id : 'invoice_cooperateReceive',
				width : 85,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				emptyText : '请选择',
				store : invoiceStore_cooperateReceive,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				selectOnFocus : true,
				
				listeners:{
					'render':function() {
						this.setValue(41);
						Ext.getCmp("invoice_cooperateReceive").getStore().reload();
					}
				}
			});
			
	/**
	 * 观光点数据源
	 */
	var attractionsStore_fit = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '31'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
									  {name : 'CL_CODE'},
									  {name : 'CL_NAME'}
									 ]
						}),
				autoLoad : true
			});

	/**
	 * 观光点控件
	 */
	var attractions_fit = new Ext.ux.form.LovCombo({
				fieldLabel : '观光点',
				id : 'attractions_fit',
				width : 245,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				store : attractionsStore_fit,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				listeners:{'change':function() {
						if(this.getValue()=="") {
							Ext.getCmp("eamt_fit").setValue("");
							Ext.getCmp("samt_fit").setValue("");
							Ext.getCmp("samt_big").setText("");
						} else {
							calculateFee(this.getValue());
						}
					}
				}
			});
			
//	/**
//	 * 观光点数据源
//	 */
//	var attractionsStore_custReceive = new Ext.data.Store({
//				proxy : new Ext.data.HttpProxy({
//							url : comboBoxUrl + '31'
//						}),
//				reader : new Ext.data.JsonReader({
//							fields : [
//									  {name : 'CL_CODE'},
//									  {name : 'CL_NAME'}
//									 ]
//						}),
//				autoLoad : true
//			});
//
//	/**
//	 * 观光点控件
//	 */
//	var attractions_custReceive = new Ext.ux.form.LovCombo({
//				fieldLabel : '观光点',
//				id : 'attractions_custReceive',
//				width : 245,
//				displayField : 'CL_NAME',
//				valueField : 'CL_CODE',
//				store : attractionsStore_custReceive,
//				mode : 'local',
//				editable : false,
//				triggerAction : 'all',
//				listeners:{'change':function() {
//						if(this.getValue()=="") {
//							Ext.getCmp("eamt_custReceive").setValue("");
//							Ext.getCmp("samt_big").setText("应收金额：");
//						} else {
//							calculateFee(this.getValue());
//						}
//					}
//				}
//			});
//			
//	/**
//	 * 观光点数据源
//	 */
//	var attractionsStore_govtReceive = new Ext.data.Store({
//				proxy : new Ext.data.HttpProxy({
//							url : comboBoxUrl + '31'
//						}),
//				reader : new Ext.data.JsonReader({
//							fields : [
//									  {name : 'CL_CODE'},
//									  {name : 'CL_NAME'}
//									 ]
//						}),
//				autoLoad : true
//			});
//
//	/**
//	 * 观光点控件
//	 */
//	var attractions_govtReceive = new Ext.ux.form.LovCombo({
//				fieldLabel : '观光点',
//				id : 'attractions_govtReceive',
//				width : 245,
//				displayField : 'CL_NAME',
//				valueField : 'CL_CODE',
//				store : attractionsStore_govtReceive,
//				mode : 'local',
//				editable : false,
//				triggerAction : 'all',
//				listeners:{'change':function() {
//						if(this.getValue()=="") {
//							Ext.getCmp("eamt_govtReceive").setValue("");
//							Ext.getCmp("samt_big").setText("应收金额：");
//						} else {
//							calculateFee(this.getValue());
//						}
//					}
//				}
//			});
//	
//	/**
//	 * 观光点数据源
//	 */
//	var attractionsStore_cooperateReceive = new Ext.data.Store({
//				proxy : new Ext.data.HttpProxy({
//							url : comboBoxUrl + '31'
//						}),
//				reader : new Ext.data.JsonReader({
//							fields : [
//									  {name : 'CL_CODE'},
//									  {name : 'CL_NAME'}
//									 ]
//						}),
//				autoLoad : true
//			});
//
//	/**
//	 * 观光点控件
//	 */
//	var attractions_cooperateReceive = new Ext.ux.form.LovCombo({
//				fieldLabel : '观光点',
//				id : 'attractions_cooperateReceive',
//				width : 245,
//				displayField : 'CL_NAME',
//				valueField : 'CL_CODE',
//				store : attractionsStore_cooperateReceive,
//				mode : 'local',
//				editable : false,
//				triggerAction : 'all',
//				listeners:{'change':function() {
//						if(this.getValue()=="") {
//							Ext.getCmp("eamt_cooperateReceive").setValue("");
//							Ext.getCmp("samt_big").setText("应收金额：");
//						} else {
//							calculateFee(this.getValue());
//						}
//					}
//				}
//			});
			
	/**
	 * 观光点数据源
	 */
	var attractionsStore_term = new Ext.data.Store({
				proxy : new Ext.data.HttpProxy({
							url : comboBoxUrl + '31'
						}),
				reader : new Ext.data.JsonReader({
							fields : [
									  {name : 'CL_CODE'},
									  {name : 'CL_NAME'}
									 ]
						}),
				autoLoad : true
			});

	/**
	 * 观光点控件
	 */
	var attractions_term = new Ext.ux.form.LovCombo({
				fieldLabel : '观光点',
				id : 'attractions_term',
				width : 245,
				displayField : 'CL_NAME',
				valueField : 'CL_CODE',
				store : attractionsStore_term,
				mode : 'local',
				editable : false,
				triggerAction : 'all',
				listeners:{'change':function() {
						if(this.getValue()=="") {
							Ext.getCmp("eamt").setValue("");
							Ext.getCmp("samt").setValue("");
							Ext.getCmp("samt_big").setText("");
						} else {
							calculateFee(this.getValue());
						}
					}
				}
			});
			
	var storereader= new Ext.data.JsonReader({
    	fields:[
    		{name :'ID'},
    		{name :'GUIDEID'},
    		{name :'GUIDENAME'},
    		{name :'INCOMETYPE'},
    		{name :'ATTRACTIONS'},
    		{name :'RECEPTION'},
    		{name :'SOURCE'},
    		{name :'TERM'},
    		{name :'NOTICEUNIT'},
    		{name :'NOTIFIER'},
    		{name :'NUM'},
    		{name :'STATWIN'},
    		{name :'STARTTIME'},
    		{name :'ENDTIME'},
    		{name :'INVOICE'},
    		{name :'EAMT'},
    		{name :'DISCOUNT'},
    		{name :'RATIO'},
    		{name :'SAMT'},
    		{name :'AAMT'},
    		{name :'SETTLETYPE'},
    		{name :'DEDUCT'},
    		{name :'FEEDBACK'},
    		{name :'REMARKED'},
    		{name :'REMARK'},
    		
    		{name :'SHOW_INCOMETYPE'},
    		{name :'SHOW_ATTRACTIONS'},
    		{name :'SHOW_DISCOUNT'}
    	]
	});
		
	/**
	 * 列表数据源
	 */
	var store = new Ext.data.Store({
		reader:storereader,
		proxy:new Ext.data.HttpProxy({
			url:clsUrl+'&methodName=getIncome&&paramCount=0'
		})
	});
	
	var sortStoreReader= new Ext.data.JsonReader({
    	fields:[
    		{name :'ID'},
    		{name :'GUIDEID'},
    		{name :'GUIDENAME'},
    		{name :'TERM'},
    		{name :'IDX'},
    		{name :'NO'},
    		
    		{name :'SHOW_TERM'}
    	]
	});
		
	/**
	 * 列表数据源
	 */
	var sortStore = new Ext.data.Store({
		reader:sortStoreReader,
		proxy:new Ext.data.HttpProxy({
			url:clsUrl+'&methodName=getEmpSortInfo&&paramCount=0'
		})
	});
		
    /**
     * 销时Panel
     */
    var endTimePanel = new Ext.FormPanel({
    	bodyStyle:'padding:20px 15px 0',
		region : 'center',
		layout : 'form',
		frame:true,
		labelAlign : 'right',
		labelWidth : 60,
		
		items : [
				{fieldLabel : '销时时间',width : 300,name : 'endTime',id : 'endTime',xtype : 'textfield',disabled:true},
				{
				    fieldLabel:'用户反馈',
				    id:'feedback',
		            defaultType:'radio', 
		            layout:'column', 
		            isFormField:true,
		            items:[
		            		{columnWidth:.27,checked:true,name:'feedback',boxLabel:'非常满意',inputValue:'222'},
		                	{columnWidth:.19,name:'feedback',boxLabel:'满意',inputValue:'223',
	                			listeners:{'render':function() {
			            			this.setValue(true);
			            		}
			            	}},
		                	{columnWidth:.27,name:'feedback',boxLabel:'基本满意',inputValue:'224'},
		            		{columnWidth:.27,name:'feedback',boxLabel:'不满意',inputValue:'225'}
		            	]
				},
				{fieldLabel : '导游提成',width : 300,name : 'deduct',id : 'deduct',xtype : 'textfield',disabled:true},
				{fieldLabel: '备注',width:300,name:'remarked',id:'remarked',xtype:'textarea',inputType :'textfield'}
				]
    });
    
    /**
	 * 保存取消按钮
	 */
	var win = new Ext.Window({
		title:'带团销时',
		width:460,
		height:270,
		layout:'border',
		closeAction:'hide',
		modal:true,
		draggable:false,
		resizable:false,
		tbar:[
		      {
		    	  text:'保存',
		    	  iconCls:'save',
		    	  handler:update
		      },
		      '-',
		      {
		    	  text:'取消',
		    	  iconCls:'cancel',
		    	  handler:function(){
		    	  	endTimePanel.getForm().reset();
      	   			win.hide();
		      	  }
		      }
		],
		items:[endTimePanel]
	});
	
    /**
     * 带团分类Panel
     */
    var incomeTypePanel = new Ext.Panel({
    	id : "incomeTypePanel",
		region : 'north',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		items :[{
		    fieldLabel:'带团分类',
		    id:'incomeType',
            defaultType:'radio', 
            layout:'column', 
            isFormField:true,
            items:[
            		{columnWidth:.15,checked:true,name:'incomeType',id:'incomeType_fit',boxLabel:'散客',inputValue:'207',
            				listeners:{
            					'check':function() {
			            			if(this.checked==true) {
			            				custReceivePanel.hide();
			            				govtReceivePanel.hide();
			            				cooperateReceivePanel.hide();
			            				termPanel.hide();
			            				fitPanel.show();
			            				formPanel.doLayout();
			            				
			            				cleanCustReceivePanel();
			            				cleanGovtReceivePanel();
			            				cleanCooperateReceivePanel();
			            				cleanTermPanel();
			            				cleanEmpInfo();
			            				
			            				Ext.getCmp("save").disable();
			            				if(saveValidateForEndTime()){
		    								Ext.getCmp("update").disable();
										}
			            			}
            					},
		            			'render':function() {
		            				this.setValue(true);
		            			}
	            		}
	            	},
                	{columnWidth:.20,name:'incomeType',id:'incomeType_custReceive',boxLabel:'局务接待',inputValue:'208',
                			listeners:{
                				'check':function() {
			            			if(this.checked==true) {
			            				fitPanel.hide();
			            				govtReceivePanel.hide();
			            				cooperateReceivePanel.hide();
			            				termPanel.hide();
			            				custReceivePanel.show();
			            				formPanel.doLayout();
			            				
			            				cleanFitPanel();
			            				cleanGovtReceivePanel();
			            				cleanCooperateReceivePanel();
			            				cleanTermPanel();	
			            				cleanEmpInfo();
			            				
			            				Ext.getCmp("save").disable();
			            				if(saveValidateForEndTime()){
		    								Ext.getCmp("update").disable();
										}
			            			}
			            	}
			        }},
			        {columnWidth:.20,name:'incomeType',id:'incomeType_govtReceive',boxLabel:'政府接待',inputValue:'245',
                			listeners:{
                				'check':function() {
			            			if(this.checked==true) {
			            				fitPanel.hide();
			            				custReceivePanel.hide();
			            				cooperateReceivePanel.hide();
			            				termPanel.hide();
			            				govtReceivePanel.show();
			            				formPanel.doLayout();
			            				
			            				cleanFitPanel();
			            				cleanCustReceivePanel();
			            				cleanCooperateReceivePanel();
			            				cleanTermPanel();	
			            				cleanEmpInfo();
			            				
			            				Ext.getCmp("save").disable();
			            				if(saveValidateForEndTime()){
		    								Ext.getCmp("update").disable();
										}
			            			}
			            	}
			        }},
			        {columnWidth:.20,name:'incomeType',id:'incomeType_cooperateReceive',boxLabel:'协作单位',inputValue:'246',
                			listeners:{
                				'check':function() {
			            			if(this.checked==true) {
			            				fitPanel.hide();
			            				custReceivePanel.hide();
			            				govtReceivePanel.hide();
			            				termPanel.hide();
			            				cooperateReceivePanel.show();
			            				formPanel.doLayout();
			            				
			            				cleanFitPanel();
			            				cleanCustReceivePanel();
			            				cleanGovtReceivePanel();
			            				cleanTermPanel();	
			            				cleanEmpInfo();
			            				
			            				Ext.getCmp("save").disable();
			            				if(saveValidateForEndTime()){
		    								Ext.getCmp("update").disable();
										}
			            			}
			            	}
			        }},
                	{columnWidth:.25,name:'incomeType',id:'incomeType_term',boxLabel:'中心业务单位',inputValue:'209',
                			listeners:{'check':function() {
		            			if(this.checked==true) {
		            				fitPanel.hide();
		            				custReceivePanel.hide();
			            			govtReceivePanel.hide();
		            				cooperateReceivePanel.hide();
		            				termPanel.show();
		            				formPanel.doLayout();
		            				
		            				cleanFitPanel();
		            				cleanCustReceivePanel();
		            				cleanGovtReceivePanel();
			            			cleanCooperateReceivePanel();
		            				cleanEmpInfo();
		            				
		            				Ext.getCmp("save").disable();
		            				if(saveValidateForEndTime()){
		    							Ext.getCmp("update").disable();
									}
		            			}
		            		}
		            }}
            	]
		}]
    });
    
    /**
     * 散客Panel
     */
    var fitPanel = new Ext.Panel({
        id : "fitPanel",
		region : 'center',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		height:170,
		items :[{
			layout : 'column',
			labelWidth : 80,
			labelAlign : 'right',
			items : [{
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .32,
						items : [
								 {fieldLabel : '导游编号',width : 85,name : 'guideID_fit',id : 'guideID_fit',xtype : 'textfield',listeners:{
								 	'blur':function() {
								 		if(this.getValue()!="" && this.getValue()!=curGuideID) {
								 		    var obj = new Object();
										
											obj.workID = this.getValue();

											obj.eName = "";
											obj.starLevel = "";
											obj.term = "";
											obj.contract = "";
											obj.leftJob = "";
											obj.startDate = "";
											obj.endDate = "";
											obj.isFormal = "";
			
									 		enableControl();
									 		getEmpInfo(obj);
								 		} else {
								 			Ext.getCmp("save").disable();
								 		}
								 		
								 		Ext.getCmp("update").disable();
								 	}
								 }},
								 {fieldLabel : '带团人数',width : 85,name : 'num_fit',id : 'num_fit',xtype : 'numberfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .31,
						items : [
								invoice_fit,
								{fieldLabel : '折扣比例',width : 85,name : 'ratio_fit',id : 'ratio_fit',xtype : 'numberfield',listeners:{'blur':function() {
										var attractionsIds = Ext.getCmp("attractions_fit").getValue();
										calculateFee(attractionsIds);
									}
								}}
								]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .37,
						items : [
								{fieldLabel : '预售金额',width : 85,name : 'eamt_fit',id : 'eamt_fit',xtype : 'numberfield'},
								{fieldLabel : '应收金额',width : 85,name : 'samt_fit',id : 'samt_fit',xtype : 'numberfield'}
								]
					}]
		},{
			layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [attractions_fit]
					},{
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '实收金额',width : 85,name : 'aamt_fit',id : 'aamt_fit',xtype : 'numberfield'}]
					}
            	  ]
		},{
			layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '备注',width : 245,name : 'remark_fit',id : 'remark_fit',xtype : 'textfield'}]
					},{
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : []
					}
            	  ]
		}]
    });
    
    /**
     * 局方接待Panel
     */
    var custReceivePanel = new Ext.Panel({
        id : "custReceivePanel",
		region : 'sourth',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		height:170,
		items :[{
			layout : 'column',
			labelWidth : 80,
			labelAlign : 'right',
			items : [{
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .32,
						items : [
								 {fieldLabel : '导游编号',width : 85,name : 'guideID_custReceive',id : 'guideID_custReceive',xtype : 'textfield',listeners:{
								 	'blur':function() {
								 		if(this.getValue()!="" && this.getValue()!=curGuideID) {
								 		    var obj = new Object();
										
											obj.workID = this.getValue();

											obj.eName = "";
											obj.starLevel = "";
											obj.term = "";
											obj.contract = "";
											obj.leftJob = "";
											obj.startDate = "";
											obj.endDate = "";
											obj.isFormal = "";
			
											enableControl();
									 		getEmpInfo(obj);
								 		} else {
								 			Ext.getCmp("save").disable();
								 		}
								 		
								 		Ext.getCmp("update").disable();
								 	}
								 }},
								 {fieldLabel : '带团人数',width : 85,name : 'num_custReceive',id : 'num_custReceive',xtype : 'numberfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .31,
						items : [
								invoice_custReceive,
								{fieldLabel : '结算方式',width : 85,name : 'settleType_custReceive',id : 'settleType_custReceive',xtype : 'textfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .37,
						items : [
								 {fieldLabel : '预售金额',width : 85,name : 'eamt_custReceive',id : 'eamt_custReceive',xtype : 'numberfield'},
								 {fieldLabel : '实收金额',width : 85,name : 'aamt_custReceive',id : 'aamt_custReceive',xtype : 'numberfield'}
								]
					}]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '接待单位',width : 245,name : 'reception_custReceive',id : 'reception_custReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '通知人',width : 85,name : 'notifier_custReceive',id : 'notifier_custReceive',xtype : 'textfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '观光点',width : 245,name : 'attractions_custReceive',id : 'attractions_custReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '点数',width : 85,name : 'points_custReceive',id : 'points_custReceive',xtype : 'numberfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '备注',width : 245,name : 'remark_custReceive',id : 'remark_custReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '客源',width : 85,name : 'source_custReceive',id : 'source_custReceive',xtype : 'textfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : []
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '导游提成',width : 85,name : 'deduct_custReceive',id : 'deduct_custReceive',xtype : 'textfield'}]
					}
            	  ]
		}]
    });
    
    /**
     * 政府接待Panel
     */
    var govtReceivePanel = new Ext.Panel({
        id : "govtReceivePanel",
		region : 'sourth',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		height:170,
		items :[{
			layout : 'column',
			labelWidth : 80,
			labelAlign : 'right',
			items : [{
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .32,
						items : [
								 {fieldLabel : '导游编号',width : 85,name : 'guideID_govtReceive',id : 'guideID_govtReceive',xtype : 'textfield',listeners:{
								 	'blur':function() {
								 		if(this.getValue()!="" && this.getValue()!=curGuideID) {
								 		    var obj = new Object();
										
											obj.workID = this.getValue();

											obj.eName = "";
											obj.starLevel = "";
											obj.term = "";
											obj.contract = "";
											obj.leftJob = "";
											obj.startDate = "";
											obj.endDate = "";
											obj.isFormal = "";
			
											enableControl();
									 		getEmpInfo(obj);
								 		} else {
								 			Ext.getCmp("save").disable();
								 		}
								 		
								 		Ext.getCmp("update").disable();
								 	}
								 }},
								 {fieldLabel : '带团人数',width : 85,name : 'num_govtReceive',id : 'num_govtReceive',xtype : 'numberfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .31,
						items : [
								invoice_govtReceive,
								{fieldLabel : '结算方式',width : 85,name : 'settleType_govtReceive',id : 'settleType_govtReceive',xtype : 'textfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .37,
						items : [
								 {fieldLabel : '预售金额',width : 85,name : 'eamt_govtReceive',id : 'eamt_govtReceive',xtype : 'numberfield'},
								 {fieldLabel : '实收金额',width : 85,name : 'aamt_govtReceive',id : 'aamt_govtReceive',xtype : 'numberfield'}
								]
					}]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '接待单位',width : 245,name : 'reception_govtReceive',id : 'reception_govtReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '通知人',width : 85,name : 'notifier_govtReceive',id : 'notifier_govtReceive',xtype : 'textfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '观光点',width : 245,name : 'attractions_govtReceive',id : 'attractions_govtReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '点数',width : 85,name : 'points_govtReceive',id : 'points_govtReceive',xtype : 'numberfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '备注',width : 245,name : 'remark_govtReceive',id : 'remark_govtReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '客源',width : 85,name : 'source_govtReceive',id : 'source_govtReceive',xtype : 'textfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : []
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '导游提成',width : 85,name : 'deduct_govtReceive',id : 'deduct_govtReceive',xtype : 'textfield'}]
					}
            	  ]
		}]
    });
    
    /**
     * 协作单位Panel
     */
    var cooperateReceivePanel = new Ext.Panel({
        id : "cooperateReceivePanel",
		region : 'sourth',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		height:170,
		items :[{
			layout : 'column',
			labelWidth : 80,
			labelAlign : 'right',
			items : [{
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .32,
						items : [
								 {fieldLabel : '导游编号',width : 85,name : 'guideID_cooperateReceive',id : 'guideID_cooperateReceive',xtype : 'textfield',listeners:{
								 	'blur':function() {
								 		if(this.getValue()!="" && this.getValue()!=curGuideID) {
								 		    var obj = new Object();
										
											obj.workID = this.getValue();

											obj.eName = "";
											obj.starLevel = "";
											obj.term = "";
											obj.contract = "";
											obj.leftJob = "";
											obj.startDate = "";
											obj.endDate = "";
											obj.isFormal = "";
			
											enableControl();
									 		getEmpInfo(obj);
								 		} else {
								 			Ext.getCmp("save").disable();
								 		}
								 		
								 		Ext.getCmp("update").disable();
								 	}
								 }},
								 {fieldLabel : '带团人数',width : 85,name : 'num_cooperateReceive',id : 'num_cooperateReceive',xtype : 'numberfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .31,
						items : [
								invoice_cooperateReceive,
								{fieldLabel : '结算方式',width : 85,name : 'settleType_cooperateReceive',id : 'settleType_cooperateReceive',xtype : 'textfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .37,
						items : [
								 {fieldLabel : '预售金额',width : 85,name : 'eamt_cooperateReceive',id : 'eamt_cooperateReceive',xtype : 'numberfield'},
								 {fieldLabel : '实收金额',width : 85,name : 'aamt_cooperateReceive',id : 'aamt_cooperateReceive',xtype : 'numberfield'}
								]
					}]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '接待单位',width : 245,name : 'reception_cooperateReceive',id : 'reception_cooperateReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '通知人',width : 85,name : 'notifier_cooperateReceive',id : 'notifier_cooperateReceive',xtype : 'textfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '观光点',width : 245,name : 'attractions_cooperateReceive',id : 'attractions_cooperateReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '点数',width : 85,name : 'points_cooperateReceive',id : 'points_cooperateReceive',xtype : 'numberfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [{fieldLabel : '备注',width : 245,name : 'remark_cooperateReceive',id : 'remark_cooperateReceive',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '客源',width : 85,name : 'source_cooperateReceive',id : 'source_cooperateReceive',xtype : 'textfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : []
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '导游提成',width : 85,name : 'deduct_cooperateReceive',id : 'deduct_cooperateReceive',xtype : 'textfield'}]
					}
            	  ]
		}]
    });
    
    /**
     * 团队Panel
     */
    var termPanel = new Ext.Panel({
        id : "termPanel",
		region : 'center',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		height:170,
		items :[{
			layout : 'column',
			labelWidth : 80,
			labelAlign : 'right',
			items : [{
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .32,
						items : [
								 {fieldLabel : '导游编号',width : 85,name : 'guideID_term',id : 'guideID_term',xtype : 'textfield',listeners:{
								 	'blur':function() {
								 		if(this.getValue()!="" && this.getValue()!=curGuideID) {
								 		    var obj = new Object();
										
											obj.workID = this.getValue();

											obj.eName = "";
											obj.starLevel = "";
											obj.term = "";
											obj.contract = "";
											obj.leftJob = "";
											obj.startDate = "";
											obj.endDate = "";
											obj.isFormal = "";
			
											enableControl();
									 		getEmpInfo(obj);
								 		} else {
								 			Ext.getCmp("save").disable();
								 		}
								 		
								 		Ext.getCmp("update").disable();
								 	}
								 }},
								 {fieldLabel : '带团人数',width : 85,name : 'num_term',id : 'num_term',xtype : 'numberfield'}
								]
					}, {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .31,
						items : [
								invoice_term,
								{fieldLabel : '折扣比例',width : 85,name : 'ratio_term',id : 'ratio_term',xtype : 'numberfield',listeners:{'blur':function() {
										var attractionsIds = Ext.getCmp("attractions_term").getValue();
										calculateFee(attractionsIds);
									}
								}}
								]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .37,
						items : [
								 {fieldLabel : '预售金额',width : 85,name : 'eamt_term',id : 'eamt_term',xtype : 'numberfield'},
								 {fieldLabel : '应收金额',width : 85,name : 'samt_term',id : 'samt_term',xtype : 'numberfield'}
								]
					}]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .629,
						items : [attractions_term]
					}, {
						layout : 'form',
						labelWidth : 70,
						labelAlign : 'right',
						columnWidth : .371,
						items : [{fieldLabel : '实收金额',width : 85,name : 'aamt_term',id : 'aamt_term',xtype : 'numberfield'}]
					}
            	  ]
		},{
            layout:'column', 
            labelWidth : 80,
			labelAlign : 'right',
            items:[
            	    {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .5,
						items : [{fieldLabel : '团队名称',width : 160,name : 'termName_term',id : 'termName_term',xtype : 'textfield'}]
					}, {
						layout : 'form',
						labelWidth : 60,
						labelAlign : 'right',
						columnWidth : .5,
						items : [{fieldLabel : '通知单位',width : 160,name : 'noticeunit_term',id : 'noticeunit_term',xtype : 'textfield'}]
					}
            	  ]
		},
		{fieldLabel : '备注',width : 245,name : 'remark_term',id : 'remark_term',xtype : 'textfield'}]
    });
    
    /**
     * 应收金额Panel
     */
    var grandtotalPanel = new Ext.Panel({
    	id : "grandtotalPanel",
		region : 'south',
		layout : 'form',
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 60,
		height:27,
		items : [{id:'samt_big',width:200,xtype:'label',html:'应收金额：',style:'font-size:20px'}]
    });
    
	/**
	 * formPanel
	 */
	var formPanel = new Ext.FormPanel({
		id : "formPanel",
		height:275,
		bodyStyle : 'padding:10px 15px 0',
		region : 'north',
		layout : 'form',
		frame : true,
		autoScroll : true,
		border : true,
		labelAlign : 'right',
		labelWidth : 80,

		items : [{
			layout : 'column',
			labelWidth : 80,
			labelAlign : 'right',
			items : [{
				layout : 'form',
				labelWidth : 60,
				labelAlign : 'right',
				columnWidth : .50,
				items : [incomeTypePanel, fitPanel, custReceivePanel, govtReceivePanel, cooperateReceivePanel, termPanel, grandtotalPanel]
				}, {
					layout : 'form',
					labelWidth : 60,
					labelAlign : 'right',
					columnWidth : .50,
					height:200,
					frame : true,
					bodyStyle : 'padding:20px 0px 17',
					items : [{
						layout : 'column',
						labelWidth : 10,
						labelAlign : 'right',
						columnWidth : .4,
						items : [{
									layout : 'form',
									labelWidth : 0,
									labelAlign : 'right',
									columnWidth : .05,
									items : [{}]
								},{
									layout : 'form',
									labelWidth : 60,
									labelAlign : 'right',
									columnWidth : .25,
									items : [{
												width : 110,
												id : 'imageBrowse',
												height : 140,
												xtype : 'box',
												hideLabel : true,
												autoEl : {
													tag : 'img',
													src : nonImage,
													style : 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);'
												}
											}]
								},{
									layout : 'form',
									labelAlign : 'right',
									columnWidth : .70,
									items : [{
											layout : 'column',
											labelAlign : 'right',
											items : [{
												layout : 'form',
												labelWidth : 10,
												labelAlign : 'right',
												columnWidth : .40,
												items : [
													{id:'eName_show',width:200,xtype:'label',html:'姓名：',style:'font-size:16px'},
													{fieldLabel : '姓名',width : 80,name : 'eName',id : 'eName',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'age_show',width:200,xtype:'label',html:'年龄：',style:'font-size:16px'},
													{fieldLabel : '年龄',width : 80,name : 'age',id : 'age',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'sex_show',width:200,xtype:'label',html:'性别：',style:'font-size:16px'},
													{fieldLabel : '性别',width : 80,name : 'sex',id : 'sex',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'workID_show',width:200,xtype:'label',html:'工号：',style:'font-size:16px'},
													{fieldLabel : '工号',width : 80,name : 'workID',id : 'workID',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'term_show',width:200,xtype:'label',html:'组别：',style:'font-size:16px'},
													{fieldLabel : '组别',width : 80,name : 'term',id : 'term',xtype : 'textfield',hidden:true,hideLabel:true}
												]
											},{
												layout : 'form',
												labelWidth : 70,
												labelAlign : 'right',
												columnWidth : .60,
												items : [
													{id:'tel_show',width:200,xtype:'label',html:'联系方式：',style:'font-size:16px'},
													{fieldLabel : '联系方式',width : 100,name : 'tel',id : 'tel',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'eLevel_show',width:200,xtype:'label',html:'英语等级：',style:'font-size:16px'},
													{fieldLabel : '英语等级',width : 100,name : 'eLevel',id : 'eLevel',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'mLevel_show',width:200,xtype:'label',html:'普通话等级：',style:'font-size:16px'},
													{fieldLabel : '普通话等级',width : 100,name : 'mLevel',id : 'mLevel',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													
													{id:'starLevel_show',width:200,xtype:'label',html:'员工星级：',style:'font-size:16px'},
													{fieldLabel : '员工星级',width : 100,name : 'starLevel',id : 'starLevel',xtype : 'textfield',hidden:true,hideLabel:true},
													{height:7},
													{id:'cCard_show',width:200,xtype:'label',html:'导游证情况：',style:'font-size:16px'},
													{fieldLabel : '导游证情况',width : 100,name : 'cCard',id : 'cCard',xtype : 'textfield',hidden:true,hideLabel:true}
												]
											}]
										}]
								}]
							}]
					}]
		}],
		tbar : [{
					text : '保存',
					id : 'save',
					iconCls : 'add',
					listeners:{'render':function() {
							this.disable();
						}
					},
					handler : function() {
						save();
					}
				}, '-', {
					text : '读卡',
					iconCls : 'modify',
					handler : function() {
				    	var url=basePath + 'JarpListener?className=cn.com.zsc.acr122u.ACR122UReaderInfo&methodName=queryCardInfo&paramCount=0'
						Ext.http.send(url,function(res){
							if (res != null && res != "") {
								var obj = new Object();
						
								obj.workID = res;
								obj.eName = "";
								obj.starLevel = "";
								obj.term = "";
								obj.contract = "";
								obj.leftJob = "";
								obj.startDate = "";
								obj.endDate = "";
								obj.isFormal = "";
								
								enableControl();
								getEmpInfo(obj);
							} else {
								Ext.Msg.show({   
					   		     title: '错误提示',   
					   		     msg: '请将卡正确放置在读卡器上！',   
					   		     buttons : Ext.Msg.OK,   
					   		     icon : Ext.Msg.ERROR   
					   		    });  
							}
						});
					}
				}, '-', {
					text : '销时',
					id : 'update',
					iconCls : 'delete',
					listeners:{'render':function() {
							this.disable();
						}
					},
					handler : function() {
						var record = basegrid.getSelectionModel().getSelected();
						
		   		        if(!record){   
				   		   Ext.Msg.show({   
				   		     title: '错误提示',   
				   		     msg: '请选择要销时的数据！',   
				   		     buttons : Ext.Msg.OK,   
				   		     icon : Ext.Msg.ERROR   
				   		    });      
			      	   	}else{
			      	   		win.show();
			      	   		
			      	   		setEndTimeAndDeduct(record);
		      	   		}
					}
				}, '-', {
					text : '带团排序',
					id : 'sort',
					iconCls : 'delete',
					handler : function() {
						sortStore.load();
						sortWin.show();
					}
				}
		],
		listeners:{'render':function() {
				fitPanel.show();
				custReceivePanel.hide();
				govtReceivePanel.hide();
				cooperateReceivePanel.hide();
				termPanel.hide();
			}
		}
	});

	/**
	 * 收入列表
	 */
	var basegrid = new Ext.grid.GridPanel({
				id : 'basegrid',
				store : store,
				split : true,
				bodyStyle : '5px 15px 0',
				region : 'center',
				border : false,
				enableColumnMove : false,
				enableHdMenu : false,
				frame : false,
				autoScroll : true,
		
				columns : [
							new Ext.grid.RowNumberer(),
							{id:'guideID',name:'guideID',header:'导游编号',width:80,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'GUIDEID'},
						    {id:'guideName',name:'guideName',header:'导游姓名',width:100,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'GUIDENAME'},
						    {header:'带团分类',width:90,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'SHOW_INCOMETYPE'},
						    {id:'incomeType',name:'incomeType',header:'带团分类',width:90,enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'INCOMETYPE'},
						    {id:'startTime',name:'startTime',header:'上团时间',width:100,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'STARTTIME',renderer:function (val){return val.substring(11, val.length)}},
						    {header:'观光点',width:250,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'SHOW_ATTRACTIONS'},
						    {id:'attractions',name:'attractions',header:'观光点',width:300,enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'ATTRACTIONS'},
						    {id:'reception',name:'reception',header:'接待单位',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'RECEPTION'},
						    {id:'source',name:'source',header:'客源',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'SOURCE'},
						    {id:'term',name:'term',header:'团队名称',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'TERM'},
						    {id:'noticeunit',name:'noticeunit',header:'通知单位',width:250,enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'NOTICEUNIT'},
						    {id:'notifier',name:'notifier',header:'通知人',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'NOTIFIER'},
						    {id:'num',name:'num',header:'带团人数',width:80,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'NUM'},
						    {id:'statwin',name:'statwin',header:'统计窗口',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'STATWIN'},
						    {id:'endTime',name:'endTime',header:'销时时间',width:120,enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'ENDTIME'},
						    {id:'invoice',name:'invoice',header:'需无发票',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'INVOICE',renderer:function (val){if (val=='0'){return '';}else {return val;}}},
						    {id:'eamt',name:'eamt',header:'预售金额',enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'EAMT'},
						    {id:'ratio',name:'ratio',header:'折扣比例',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'RATIO'},
						    {id:'samt',name:'samt',header:'应收金额',enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'SAMT'},
						    {id:'aamt',name:'aamt',header:'实收金额',enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'AAMT'},
						    {id:'settleType',name:'settleType',header:'结算方式',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'SETTLETYPE'},
						    {id:'deduct',name:'deduct',header:'导游提成',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'DEDUCT'},
						    {id:'feedback',name:'feedback',header:'用户反馈',enableColumnMove:false,sortable:true,hidden:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'FEEDBACK'},
						    {id:'remarked',name:'remarked',header:'备注',hidden:true,width:250,enableColumnMove:false,sortable:true,hideCollapseTool:false,enableHdMenu:false,enableColumnResize:false,dataIndex:'REMARKED'}
						  ],
				listeners:{'dblclick':function() {
						var record = basegrid.getSelectionModel().getSelected();
						
						if(record){
						    var obj = new Object();
						
							obj.workID = record.data.GUIDEID;
							obj.eName = "";
							obj.starLevel = "";
							obj.term = "";
							obj.contract = "";
							obj.leftJob = "";
							obj.startDate = "";
							obj.endDate = "";
							obj.isFormal = "";
							
							Ext.getCmp("incomeType_fit").enable();
							Ext.getCmp("incomeType_custReceive").enable();
							Ext.getCmp("incomeType_govtReceive").enable();
							Ext.getCmp("incomeType_cooperateReceive").enable();
							Ext.getCmp("incomeType_term").enable();
							Ext.getCmp("update").enable();
							
							getEmpInfo(obj);
							getIncomeInfo(record);
							disableControl(record);
							
							curGuideID = record.data.GUIDEID;
						}
					}
				}
			});
			
	var sm2 = new Ext.grid.RowSelectionModel({singleSelect: true});
	
	/**
	 * 用户列表
	 */
	var sortGrid;
	
	var emptyPanel = new Ext.Panel({
		id:'emptyPanel',
		bodyStyle:'padding:20px 15px 0',
		region:'center',
		layout:'form',
		frame:true,
		labelWidth:100,
		labelAlign:'right',
		listeners:{'render':function() {
				var sortDiv = document.createElement("div");
				sortDiv.setAttribute("id", "sortDiv");
				emptyPanel.getEl().dom.childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0].style.paddingLeft = 0;
				emptyPanel.getEl().dom.childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0].style.paddingLeft = 0;
				emptyPanel.getEl().dom.childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0].style.paddingRight = 0;
				emptyPanel.getEl().dom.childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0].style.paddingTop = 0;
				emptyPanel.getEl().dom.childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[0].appendChild(sortDiv);
				
				sortGrid = new Ext.grid.GridPanel( {
						id :'sortGrid',
						store :sortStore,
						split :true,
						height:500,
						width:700,
						bodyStyle:'5px 15px 0',
						region :'center',
						border :false,
						enableColumnMove:false,                                           
					  	enableHdMenu:false,
						frame :false,
						autoScroll :true,
						viewConfig: {
				        	forceFit: true
				    	},
				    	columns: [
				     	            new Ext.grid.RowNumberer(),
				    	          	{header:'导游编号',enableColumnMove:false,sortable:true,hideCollapseTool:false, enableHdMenu:false,enableColumnResize :false,dataIndex: 'GUIDEID'},
				    	          	{header:'导游姓名',sortable:true,enableColumnMove:false,enableHdMenu:false,enableColumnResize :false, dataIndex: 'GUIDENAME'},
				    	          	{header:'组别',sortable:true,enableColumnMove:false,enableHdMenu:false,enableColumnResize :false, dataIndex: 'SHOW_TERM'},
				    	          	{header:'组别',hidden:true,sortable:true,enableColumnMove:false,enableHdMenu:false,enableColumnResize :false, dataIndex: 'TERM'},
				    	          	{header:'IDX',sortable:true,enableColumnMove:false,enableHdMenu:false,enableColumnResize :false, dataIndex: 'IDX'},
				    	          	{header:'本日带团次数',sortable:true,enableColumnMove:false,enableHdMenu:false,enableColumnResize :false, dataIndex: 'NO'}
				    	],
				    	renderTo:sortDiv,
				    	sm:sm2,
				    	enableDragDrop :true,
				    	dropConfig: {
				            appendOnly:true
				        },
				        ddGroup: "GridDD"
				});
				
				/**
				 * 拖动排序
				 */
			    var ddrow = new Ext.dd.DropTarget(sortGrid.getEl(), {
			        ddGroup: "GridDD",  
			        
			        notifyDrop : function(dd, e, data) {
						var rows = sortGrid.getSelectionModel().getSelections();
						var count = rows.length;
						var cindex = dd.getDragData(e).rowIndex;
						var array = [];

						for (var i = 0; i < count; i++) {
							var index = cindex + i;
							array.push(index);
						}

						sortStore.remove(store.getById(data.selections[0].id));
						sortStore.insert(cindex, data.selections);

						sortGrid.getView().refresh();
						sortGrid.getSelectionModel().selectRows(array);
					}
			    });
			}
		}
	});
	
	/**
	 * 导游带团排序窗口
	 */
	var sortWin = new Ext.Window({
		title:'导游带团排序',
		width:700,
		height:500,
		layout:'border',
		closeAction:'hide',
		modal:true,
		draggable:false,
		resizable:false,
		tbar:[
		      {
		    	  text:'保存',
		    	  iconCls:'save',
		    	  handler:function() {
		    	  	resetEmpSort();
		    	  }
		      },
		      '-',
		      {
		    	  text:'取消',
		    	  iconCls:'cancel',
		    	  handler:function(){
      	   			sortWin.hide();
		      	  }
		      }
		],
		items:[emptyPanel]
	});
	
	function resetEmpSort() {
		var resultNode = [];

		var storeLength = sortStore.getCount();

		var obj;
		var recordModStr = "[";
		
		for (var i=0; i<storeLength; i++) {
			obj = new Object();
			obj.guideID = sortStore.getAt(i).data.GUIDEID;
			obj.guideName = sortStore.getAt(i).data.GUIDENAME;
			obj.term = sortStore.getAt(i).data.TERM;
			obj.no = sortStore.getAt(i).data.NO;
			obj.idx = i;
			
			recordModStr += Ext.util.JSON.encode(obj);
			
			if(i < storeLength - 1) {
				recordModStr += ",";   
			}
		}
		
		recordModStr += "]";
		
		var url=clsUrl+'&methodName=sortEmployee&paramCount=0'
		
    	httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onSortRtn;
		httpReq.open("POST",url, true);
		httpReq.send(recordModStr);
	}
	
	function onSortRtn(){
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
		   		if(httpReq.responseText == "success"){
		   			Ext.Msg.show({   
		    	   		title : '成功提示',
		    	   		width:200,
		   				msg : '保存成功！',  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.INFO   
		   			});
		   			
		   			sortWin.hide();
		   			httpReq=null;
		   		}else{
		   			Ext.Msg.show({   
		    	   		title : '错误提示',
		    	   		width:200,
		   				msg : httpReq.responseText,  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.ERROR   
		   			});  
		   			httpReq=null;
		   		}
		   	}
		}
	}

	var viewport = new Ext.Viewport({
				layout : 'border',
				items : [formPanel, basegrid]
			});
		
	/**
	 * 新增收入
	 */
	function save(){
		if(!saveValidate()){
		    return;	
		}
		
		var obj = new Object();
		
		var icType = formPanel.form.findField("incomeType").getGroupValue();
		
		if (icType == 207) {
	        obj.guideID = Ext.getCmp("guideID_fit").getValue();
			obj.guideName = Ext.getCmp("eName").getValue();
			obj.incomeType = formPanel.form.findField("incomeType").getGroupValue();
			obj.attractions = Ext.getCmp("attractions_fit").getValue();
			obj.reception = "";
			obj.source = "";
			obj.term = "";
			obj.noticeunit = "";
			obj.notifier = "";
			obj.num = Ext.getCmp("num_fit").getValue();
			obj.statwin = "";
			obj.invoice = Ext.getCmp("invoice_fit").getValue();
			obj.eamt = Ext.getCmp("eamt_fit").getValue();
			obj.discount = "";
			obj.ratio = Ext.getCmp("ratio_fit").getValue();
			obj.samt = Ext.getCmp("samt_fit").getValue();
			obj.aamt = Ext.getCmp("aamt_fit").getValue();
			obj.settleType = "";
			obj.deduct = "";
			obj.feedback = "";
			obj.remarked = "";
			obj.remark = Ext.getCmp("remark_fit").getValue();
			obj.points = "";
		} else if(icType==208) {
			obj.guideID = Ext.getCmp("guideID_custReceive").getValue();
			obj.guideName = Ext.getCmp("eName").getValue();
			obj.incomeType = formPanel.form.findField("incomeType").getGroupValue();
			obj.attractions = "[" + Ext.getCmp("attractions_custReceive").getValue() + "]";
			obj.reception = Ext.getCmp("reception_custReceive").getValue();
			obj.source = Ext.getCmp("source_custReceive").getValue();
			obj.term = "";
			obj.noticeunit = "";
			obj.notifier = Ext.getCmp("notifier_custReceive").getValue();
			obj.num = Ext.getCmp("num_custReceive").getValue();			
			obj.statwin = "";
			obj.invoice = Ext.getCmp("invoice_custReceive").getValue();
			obj.eamt = Ext.getCmp("eamt_custReceive").getValue();
			obj.discount = "";
			obj.ratio = "";
			obj.samt = "";
			obj.aamt = Ext.getCmp("aamt_custReceive").getValue();
			obj.settleType = Ext.getCmp("settleType_custReceive").getValue();
			obj.deduct = Ext.getCmp("deduct_custReceive").getValue();
			obj.feedback = "";
			obj.remarked = "";
			obj.remark = Ext.getCmp("remark_custReceive").getValue();
			obj.points = Ext.getCmp("points_custReceive").getValue();
		} else if(icType==245) {
			obj.guideID = Ext.getCmp("guideID_govtReceive").getValue();
			obj.guideName = Ext.getCmp("eName").getValue();
			obj.incomeType = formPanel.form.findField("incomeType").getGroupValue();
			obj.attractions = "[" + Ext.getCmp("attractions_govtReceive").getValue() + "]";
			obj.reception = Ext.getCmp("reception_govtReceive").getValue();
			obj.source = Ext.getCmp("source_govtReceive").getValue();
			obj.term = "";
			obj.noticeunit = "";
			obj.notifier = Ext.getCmp("notifier_govtReceive").getValue();
			obj.num = Ext.getCmp("num_govtReceive").getValue();			
			obj.statwin = "";
			obj.invoice = Ext.getCmp("invoice_govtReceive").getValue();
			obj.eamt = Ext.getCmp("eamt_govtReceive").getValue();
			obj.discount = "";
			obj.ratio = "";
			obj.samt = "";
			obj.aamt = Ext.getCmp("aamt_govtReceive").getValue();
			obj.settleType = Ext.getCmp("settleType_govtReceive").getValue();
			obj.deduct = Ext.getCmp("deduct_govtReceive").getValue();
			obj.feedback = "";
			obj.remarked = "";
			obj.remark = Ext.getCmp("remark_govtReceive").getValue();
			obj.points = Ext.getCmp("points_govtReceive").getValue();
		} else if(icType==246) {
			obj.guideID = Ext.getCmp("guideID_cooperateReceive").getValue();
			obj.guideName = Ext.getCmp("eName").getValue();
			obj.incomeType = formPanel.form.findField("incomeType").getGroupValue();
			obj.attractions = "[" + Ext.getCmp("attractions_cooperateReceive").getValue() + "]";
			obj.reception = Ext.getCmp("reception_cooperateReceive").getValue();
			obj.source = Ext.getCmp("source_cooperateReceive").getValue();
			obj.term = "";
			obj.noticeunit = "";
			obj.notifier = Ext.getCmp("notifier_cooperateReceive").getValue();
			obj.num = Ext.getCmp("num_cooperateReceive").getValue();			
			obj.statwin = "";
			obj.invoice = Ext.getCmp("invoice_cooperateReceive").getValue();
			obj.eamt = Ext.getCmp("eamt_cooperateReceive").getValue();
			obj.discount = "";
			obj.ratio = "";
			obj.samt = "";
			obj.aamt = Ext.getCmp("aamt_cooperateReceive").getValue();
			obj.settleType = Ext.getCmp("settleType_cooperateReceive").getValue();
			obj.deduct = Ext.getCmp("deduct_cooperateReceive").getValue();
			obj.feedback = "";
			obj.remarked = "";
			obj.remark = Ext.getCmp("remark_cooperateReceive").getValue();
			obj.points = Ext.getCmp("points_cooperateReceive").getValue();
		} else if(icType ==209) {
			obj.guideID = Ext.getCmp("guideID_term").getValue();
			obj.guideName = Ext.getCmp("eName").getValue();
			obj.incomeType = formPanel.form.findField("incomeType").getGroupValue();
			obj.attractions = Ext.getCmp("attractions_term").getValue();
			obj.reception = "";
			obj.source = "";
			obj.term = Ext.getCmp("termName_term").getValue();
			obj.noticeunit = Ext.getCmp("noticeunit_term").getValue();
			obj.notifier = "";
			obj.num = Ext.getCmp("num_term").getValue();			
			obj.statwin = "";
			obj.invoice = Ext.getCmp("invoice_term").getValue();
			obj.eamt = Ext.getCmp("eamt_term").getValue();
			obj.discount = "";
			obj.ratio = Ext.getCmp("ratio_term").getValue();
			obj.samt = Ext.getCmp("samt_term").getValue();
			obj.aamt = Ext.getCmp("aamt_term").getValue();
			obj.settleType = "";
			obj.deduct = "";
			obj.feedback = "";      
			obj.remarked = "";
			obj.remark = Ext.getCmp("remark_term").getValue();
			obj.points = "";
		}
			
		var url=clsUrl+'&methodName=insertIncome&paramCount=0'
		
		httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onSaveRtn;
		httpReq.open("POST",url, true);
		httpReq.send(Ext.util.JSON.encode(obj));
	}
	
	function onSaveRtn(){
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
		   		if(httpReq.responseText == "success"){
		   			Ext.Msg.show({   
		    	   		title : '成功提示',
		    	   		width:200,
		   				msg : '保存成功！',  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.INFO   
		   			});
					
		   			updateGuideNum();
		   			store.reload();
		   			formPanel.getForm().reset();
		   			Ext.getCmp("save").disable();
		   		}else{
		   			Ext.Msg.show({   
		    	   		title : '错误提示',
		    	   		width:200,
		   				msg : httpReq.responseText,  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.ERROR   
		   			});  
		   			httpReq=null;
		   		}
		   	}
		}
	}
	
	/**
	 * 更新带团次数
	 */
	function updateGuideNum() {
		var icType = formPanel.form.findField("incomeType").getGroupValue();
		
		var obj = new Object();
		
		if (icType == 207) {
	        obj.guideID = Ext.getCmp("guideID_fit").getValue();
		} else if(icType==208) {
			obj.guideID = Ext.getCmp("guideID_custReceive").getValue();
		} else if(icType==245) {
			obj.guideID = Ext.getCmp("guideID_govtReceive").getValue();
		} else if(icType==246) {
			obj.guideID = Ext.getCmp("guideID_cooperateReceive").getValue();
		} else if(icType ==209) {
			obj.guideID = Ext.getCmp("guideID_term").getValue();
		}
		
		var url=clsUrl+'&methodName=updateGuideNum&paramCount=0'
		
		httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onUpdateGuideNumRtn;
		httpReq.open("POST",url, true);
		httpReq.send(Ext.util.JSON.encode(obj));
	}
	
	function onUpdateGuideNumRtn(){
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
				httpReq=null;		   		
		   	}
		}
	}
	
	/**
	 * 更新收入
	 */
	function update() {
		var record = basegrid.getSelectionModel().getSelected();
		
		var obj = new Object();
		obj.id = record.data.ID;
		obj.endTime = Ext.getCmp("endTime").getValue();
		obj.feedback = endTimePanel.form.findField("feedback").getGroupValue();
		obj.deduct = Ext.getCmp("deduct").getValue();
		obj.remarked = Ext.getCmp("remarked").getValue();
		
		obj.starLevel = starLevel;
		obj.attractionsNums = attractionsNums;
		obj.incomeType = incomeType;
		obj.guideID = record.data.GUIDEID;
		obj.guideName = record.data.GUIDENAME;
		obj.samt = record.data.SAMT;		
		
		if(endTimePanel.form.findField("feedback").getGroupValue()==225 && Ext.getCmp("remarked").getValue()=="") {
			Ext.getCmp("remarked").markInvalid("请填写不满意原因");
			return false;
		}
	
		var url=clsUrl+'&methodName=updateIncome&paramCount=0'
		
		httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onUpdateRtn;
		httpReq.open("POST",url, true);
		httpReq.send(Ext.util.JSON.encode(obj));
	}
	
	function onUpdateRtn(){
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
		   		if(httpReq.responseText == "success"){
		   			Ext.Msg.show({   
		    	   		title : '成功提示',
		    	   		width:200,
		   				msg : '保存成功！',  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.INFO   
		   			});
					
		   			store.reload();
		   			formPanel.getForm().reset();
		   			endTimePanel.getForm().reset();
		   			enableControl();
					
		   			win.hide();
		   			httpReq=null;
		   		}else{
		   			Ext.Msg.show({   
		    	   		title : '错误提示',
		    	   		width:200,
		   				msg : httpReq.responseText,  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.ERROR   
		   			});  
		   			httpReq=null;
		   		}
		   	}
		}
	}
	
	/**
	 * 计算观光点费用
	 */
	function calculateFee(attractionsIds) {
		if(attractionsIds=="") {
			return;
		}
		
		var obj = new Object();
		obj.attractionsIds = attractionsIds;
		
		var url=clsUrl+'&methodName=calculateFee&paramCount=0'
		
    	httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onCalculateRtn;
		httpReq.open("POST",url, true);
		httpReq.send(Ext.util.JSON.encode(obj));
	}
	
	function onCalculateRtn() {
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
		   		if(httpReq.responseText != "数据库操作失败"){
		   			var icType = formPanel.form.findField("incomeType").getGroupValue();
		   			
		   			var fee = httpReq.responseText;
		   			
		   			if(icType == 207) {
		   				Ext.getCmp("eamt_fit").setValue(fee);
		   				
		   				if (Ext.getCmp("ratio_fit").getValue()!="") {
		   					Ext.getCmp("samt_fit").setValue(fee*Ext.getCmp("ratio_fit").getValue());
		   					Ext.getCmp("samt_big").setText("应收金额：" + fee*Ext.getCmp("ratio_fit").getValue());
		   				} else {
		   					Ext.getCmp("samt_fit").setValue(fee);
		   					Ext.getCmp("samt_big").setText("应收金额：" + fee);
		   				}
		   			} else if(icType == 208) {
	   					Ext.getCmp("eamt_custReceive").setValue(fee);
						Ext.getCmp("samt_big").setText("应收金额：" + fee);
		   			} else if(icType == 245) {
	   					Ext.getCmp("eamt_govtReceive").setValue(fee);
						Ext.getCmp("samt_big").setText("应收金额：" + fee);
		   			} else if(icType == 246) {
	   					Ext.getCmp("eamt_cooperateReceive").setValue(fee);
						Ext.getCmp("samt_big").setText("应收金额：" + fee);
		   			} else if(icType == 209) {
		   				Ext.getCmp("eamt_term").setValue(fee);
		   				
		   				if (Ext.getCmp("ratio_term").getValue()!="") {
		   					Ext.getCmp("samt_term").setValue(fee*Ext.getCmp("ratio_term").getValue());
		   					Ext.getCmp("samt_big").setText("应收金额：" + fee*Ext.getCmp("ratio_term").getValue());
		   				} else {
		   					Ext.getCmp("samt_term").setValue(fee);
		   					Ext.getCmp("samt_big").setText("应收金额：" + fee);
		   				}
		   			}
		   			
					httpReq=null;
		   		}else{
		   			Ext.Msg.show({   
		    	   		title : '错误提示',
		    	   		width:200,
		   				msg :httpReq.responseText,  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.ERROR   
		   			});  
		   			httpReq=null;
		   		}
		   	}
		}
	}
	
	/**
	 * 获取收入信息
	 */
	function getIncomeInfo(record) {
		var icType = record.data.INCOMETYPE;
		
		if(icType == 207) {
			Ext.get('incomeType_fit').dom.click();
			
			Ext.getCmp("guideID_fit").setValue(record.data.GUIDEID);
			Ext.getCmp("num_fit").setValue(record.data.NUM);
			Ext.getCmp("ratio_fit").setValue(record.data.RATIO==0?"":record.data.RATIO);
			Ext.getCmp("invoice_fit").setValue(record.data.INVOICE);
			Ext.getCmp("eamt_fit").setValue(record.data.EAMT);
			Ext.getCmp("samt_fit").setValue(record.data.SAMT);
			Ext.getCmp("aamt_fit").setValue(record.data.AAMT);
			Ext.getCmp("attractions_fit").setValue(record.data.ATTRACTIONS);
			Ext.getCmp("remark_fit").setValue(record.data.REMARK);
			Ext.getCmp("samt_big").setText("应收金额：" + record.data.SAMT);
		} else if(icType == 208){
			Ext.get('incomeType_custReceive').dom.click();
			
			Ext.getCmp("guideID_custReceive").setValue(record.data.GUIDEID);
			Ext.getCmp("num_custReceive").setValue(record.data.NUM);
			Ext.getCmp("invoice_custReceive").setValue(record.data.INVOICE);
			Ext.getCmp("settleType_custReceive").setValue(record.data.SETTLETYPE);
			Ext.getCmp("eamt_custReceive").setValue(record.data.EAMT);
			Ext.getCmp("aamt_custReceive").setValue(record.data.AAMT);
			Ext.getCmp("reception_custReceive").setValue(record.data.RECEPTION);
			Ext.getCmp("notifier_custReceive").setValue(record.data.NOTIFIER);
			Ext.getCmp("attractions_custReceive").setValue(record.data.ATTRACTIONS);
			Ext.getCmp("source_custReceive").setValue(record.data.SOURCE);
			Ext.getCmp("remark_custReceive").setValue(record.data.REMARK);
			Ext.getCmp("deduct_custReceive").setValue(record.data.DEDUCT);
			Ext.getCmp("samt_big").setText("应收金额：" + record.data.SAMT);
		} else if(icType == 245){
			Ext.get('incomeType_govtReceive').dom.click();
			
			Ext.getCmp("guideID_govtReceive").setValue(record.data.GUIDEID);
			Ext.getCmp("num_govtReceive").setValue(record.data.NUM);
			Ext.getCmp("invoice_govtReceive").setValue(record.data.INVOICE);
			Ext.getCmp("settleType_govtReceive").setValue(record.data.SETTLETYPE);
			Ext.getCmp("eamt_govtReceive").setValue(record.data.EAMT);
			Ext.getCmp("aamt_govtReceive").setValue(record.data.AAMT);
			Ext.getCmp("reception_govtReceive").setValue(record.data.RECEPTION);
			Ext.getCmp("notifier_govtReceive").setValue(record.data.NOTIFIER);
			Ext.getCmp("attractions_govtReceive").setValue(record.data.ATTRACTIONS);
			Ext.getCmp("source_govtReceive").setValue(record.data.SOURCE);
			Ext.getCmp("remark_govtReceive").setValue(record.data.REMARK);
			Ext.getCmp("deduct_govtReceive").setValue(record.data.DEDUCT);
			Ext.getCmp("samt_big").setText("应收金额：" + record.data.SAMT);
		} else if(icType == 246){
			Ext.get('incomeType_cooperateReceive').dom.click();
			
			Ext.getCmp("guideID_cooperateReceive").setValue(record.data.GUIDEID);
			Ext.getCmp("num_cooperateReceive").setValue(record.data.NUM);
			Ext.getCmp("invoice_cooperateReceive").setValue(record.data.INVOICE);
			Ext.getCmp("settleType_cooperateReceive").setValue(record.data.SETTLETYPE);
			Ext.getCmp("eamt_cooperateReceive").setValue(record.data.EAMT);
			Ext.getCmp("aamt_cooperateReceive").setValue(record.data.AAMT);
			Ext.getCmp("reception_cooperateReceive").setValue(record.data.RECEPTION);
			Ext.getCmp("notifier_cooperateReceive").setValue(record.data.NOTIFIER);
			Ext.getCmp("attractions_cooperateReceive").setValue(record.data.ATTRACTIONS);
			Ext.getCmp("source_cooperateReceive").setValue(record.data.SOURCE);
			Ext.getCmp("remark_cooperateReceive").setValue(record.data.REMARK);
			Ext.getCmp("deduct_cooperateReceive").setValue(record.data.DEDUCT);
			Ext.getCmp("samt_big").setText("应收金额：" + record.data.SAMT);
		} else if(icType == 209) {
			Ext.get('incomeType_term').dom.click();
			
			Ext.getCmp("guideID_term").setValue(record.data.GUIDEID);
			Ext.getCmp("num_term").setValue(record.data.NUM);
			Ext.getCmp("invoice_term").setValue(record.data.INVOICE);
			Ext.getCmp("ratio_term").setValue(record.data.RATIO==0?"":record.data.RATIO);
			Ext.getCmp("eamt_term").setValue(record.data.EAMT);
			Ext.getCmp("samt_term").setValue(record.data.SAMT);
			Ext.getCmp("aamt_term").setValue(record.data.AAMT);
			Ext.getCmp("attractions_term").setValue(record.data.ATTRACTIONS);
			Ext.getCmp("termName_term").setValue(record.data.TERM);
			Ext.getCmp("noticeunit_term").setValue(record.data.NOTICEUNIT);
			Ext.getCmp("remark_term").setValue(record.data.REMARK);
			Ext.getCmp("samt_big").setText("应收金额：" + record.data.SAMT);
		}
	}
	
	/**
	 * 获取员工信息
	 */
	function getEmpInfo(obj) {
		var url=clsUrl+'&methodName=calculateFee&paramCount=0'
		var url=basePath + 'JarpListener?className=cn.com.zsc.hr.EmployeeMessages&methodName=getEmployee&paramCount=0';
		
    	httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onGetEmpInfoRtn;
		httpReq.open("POST",url, true);
		httpReq.send(Ext.util.JSON.encode(obj));
	}
	
	function onGetEmpInfoRtn() {
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
		   		if(httpReq.responseText != "数据库操作失败"){
		   			var icType = formPanel.form.findField("incomeType").getGroupValue();
		   			
		   			if(httpReq.responseText!="[]") {
			   			var objArr = eval("("+httpReq.responseText+")");
						
			   			if(icType == 207) {
			   			    Ext.getCmp("guideID_fit").setValue(objArr[0].WORKID);
			   			} else if(icType == 208) {
			   				Ext.getCmp("guideID_custReceive").setValue(objArr[0].WORKID);
			   			} else if(icType == 245) {
			   				Ext.getCmp("guideID_govtReceive").setValue(objArr[0].WORKID);
			   			} else if(icType == 246) {
			   				Ext.getCmp("guideID_cooperateReceive").setValue(objArr[0].WORKID);
			   			} else if(icType == 209) {
			   				Ext.getCmp("guideID_term").setValue(objArr[0].WORKID);
			   			}
			   			
			   			Ext.getCmp("eName_show").setText("姓名："+objArr[0].ENAME);
			   			Ext.getCmp("eName").setValue(objArr[0].ENAME);
			   			Ext.getCmp("age_show").setText("年龄："+objArr[0].AGE);
			   			Ext.getCmp("sex_show").setText("性别："+objArr[0].SHOW_SEX);
			   			Ext.getCmp("workID_show").setText("工号："+objArr[0].WORKID);
			   			Ext.getCmp("term_show").setText("组别："+objArr[0].SHOW_TERM);
			   			Ext.getCmp("tel_show").setText("联系方式："+objArr[0].TEL);
			   			Ext.getCmp("eLevel_show").setText("英语等级："+objArr[0].SHOW_ELEVEL);
			   			Ext.getCmp("mLevel_show").setText("普通话等级："+objArr[0].SHOW_MLEVEL);
			   			Ext.getCmp("starLevel_show").setText("员工星级："+objArr[0].SHOW_STARLEVEL);
			   			Ext.getCmp("cCard_show").setText("导游证情况："+objArr[0].SHOW_CCARD);
			   			
			   			var photoPath = objArr[0].PHOTO;
						if(photoPath=="") {
						    photoPath = basePath + 'images/zanwu.jpg';
						} else {
						    photoPath = photoPath.substring(photoPath.indexOf("photo"), photoPath.length);
							photoPath = photoPath.replace("$","\\");	
						}
						
						Ext.get('imageBrowse').dom.src = photoPath;
		   			} else {
		   				Ext.Msg.show({   
			    	   		title : '错误提示',
			    	   		width:200,
			   				msg :'导游不存在',  
				       		buttons : Ext.Msg.OK,   
				       		icon : Ext.Msg.ERROR   
		   				});
		   				
		   				Ext.getCmp("save").disable();
		   			}
		   			httpReq=null;
		   		}else{
		   			Ext.Msg.show({   
		    	   		title : '错误提示',
		    	   		width:200,
		   				msg :httpReq.responseText,  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.ERROR   
		   			});  
		   			httpReq=null;
		   		}
		   	}
		}
	}
	
	/**
	 * 锁定控件
	 */
	function disableControl(record) {
		var icType = record.data.INCOMETYPE;
		
		if(icType == 207) {
			Ext.getCmp("incomeType_custReceive").disable();
			Ext.getCmp("incomeType_govtReceive").disable();
			Ext.getCmp("incomeType_cooperateReceive").disable();
			Ext.getCmp("incomeType_term").disable();
			
			Ext.getCmp("num_fit").disable();
			Ext.getCmp("attractions_fit").disable();
			Ext.getCmp("ratio_fit").disable();
			Ext.getCmp("invoice_fit").disable();
			Ext.getCmp("eamt_fit").disable();
			Ext.getCmp("samt_fit").disable();
			Ext.getCmp("aamt_fit").disable();
			Ext.getCmp("remark_fit").disable();
		} else if(icType == 208) {
			Ext.getCmp("incomeType_fit").disable();
			Ext.getCmp("incomeType_govtReceive").disable();
			Ext.getCmp("incomeType_cooperateReceive").disable();
			Ext.getCmp("incomeType_term").disable();
			
			Ext.getCmp("num_custReceive").disable();
			Ext.getCmp("invoice_custReceive").disable();
			Ext.getCmp("settleType_custReceive").disable();
			Ext.getCmp("eamt_custReceive").disable();
			Ext.getCmp("aamt_custReceive").disable();
			Ext.getCmp("reception_custReceive").disable();
			Ext.getCmp("notifier_custReceive").disable();
			Ext.getCmp("attractions_custReceive").disable();
			Ext.getCmp("source_custReceive").disable();
			Ext.getCmp("deduct_custReceive").disable();
			Ext.getCmp("points_custReceive").disable();
			Ext.getCmp("remark_custReceive").disable();
		} else if(icType == 245) {
			Ext.getCmp("incomeType_fit").disable();
			Ext.getCmp("incomeType_custReceive").disable();
			Ext.getCmp("incomeType_cooperateReceive").disable();
			Ext.getCmp("incomeType_term").disable();
			
			Ext.getCmp("num_govtReceive").disable();
			Ext.getCmp("invoice_govtReceive").disable();
			Ext.getCmp("settleType_govtReceive").disable();
			Ext.getCmp("eamt_govtReceive").disable();
			Ext.getCmp("aamt_govtReceive").disable();
			Ext.getCmp("reception_govtReceive").disable();
			Ext.getCmp("notifier_govtReceive").disable();
			Ext.getCmp("attractions_govtReceive").disable();
			Ext.getCmp("source_govtReceive").disable();
			Ext.getCmp("deduct_govtReceive").disable();
			Ext.getCmp("points_govtReceive").disable();
			Ext.getCmp("remark_govtReceive").disable();
		} else if(icType == 246) {
			Ext.getCmp("incomeType_fit").disable();
			Ext.getCmp("incomeType_custReceive").disable();
			Ext.getCmp("incomeType_govtReceive").disable();
			Ext.getCmp("incomeType_term").disable();
			
			Ext.getCmp("num_cooperateReceive").disable();
			Ext.getCmp("invoice_cooperateReceive").disable();
			Ext.getCmp("settleType_cooperateReceive").disable();
			Ext.getCmp("eamt_cooperateReceive").disable();
			Ext.getCmp("aamt_cooperateReceive").disable();
			Ext.getCmp("reception_cooperateReceive").disable();
			Ext.getCmp("notifier_cooperateReceive").disable();
			Ext.getCmp("attractions_cooperateReceive").disable();
			Ext.getCmp("source_cooperateReceive").disable();
			Ext.getCmp("deduct_cooperateReceive").disable();
			Ext.getCmp("points_cooperateReceive").disable();
			Ext.getCmp("remark_cooperateReceive").disable();
		} else if(icType == 209) {
			Ext.getCmp("incomeType_fit").disable();
			Ext.getCmp("incomeType_custReceive").disable();
			Ext.getCmp("incomeType_govtReceive").disable();
			Ext.getCmp("incomeType_cooperateReceive").disable();
			
			Ext.getCmp("num_term").disable();
			Ext.getCmp("invoice_term").disable();
			Ext.getCmp("ratio_term").disable();
			Ext.getCmp("eamt_term").disable();
			Ext.getCmp("samt_term").disable();
			Ext.getCmp("aamt_term").disable();
			Ext.getCmp("attractions_term").disable();
			Ext.getCmp("termName_term").disable();
			Ext.getCmp("noticeunit_term").disable();
			Ext.getCmp("remark_term").disable();
		}
		
		if(record.data.ENDTIME!=null && record.data.ENDTIME!="") {
			Ext.getCmp("update").disable();
		}
		
		Ext.getCmp("save").disable();
	}
	
	/**
	 * 解锁控件
	 */
	function enableControl() {
		var icType = formPanel.form.findField("incomeType").getGroupValue();
		
		if (icType == 207) {
			Ext.getCmp("save").enable();
			Ext.getCmp("num_fit").enable();
			Ext.getCmp("attractions_fit").enable();
			Ext.getCmp("invoice_fit").enable();
			Ext.getCmp("ratio_fit").enable();
			Ext.getCmp("aamt_fit").enable();
			Ext.getCmp("incomeType_custReceive").enable();
			Ext.getCmp("incomeType_govtReceive").enable();
			Ext.getCmp("incomeType_cooperateReceive").enable();
			Ext.getCmp("incomeType_term").enable();
			
			cleanFitPanelWithoutGuideID();
			cleanEmpInfo();
		} else if (icType == 208) {
			Ext.getCmp("save").enable();
			Ext.getCmp("num_custReceive").enable();
			Ext.getCmp("reception_custReceive").enable();
			Ext.getCmp("attractions_custReceive").enable();
			Ext.getCmp("invoice_custReceive").enable();
			Ext.getCmp("settleType_custReceive").enable();
			Ext.getCmp("aamt_custReceive").enable();
			Ext.getCmp("notifier_custReceive").enable();
			Ext.getCmp("source_custReceive").enable();
			Ext.getCmp("deduct_custReceive").enable();
			Ext.getCmp("incomeType_fit").enable();
			Ext.getCmp("incomeType_govtReceive").enable();
			Ext.getCmp("incomeType_cooperateReceive").enable();
			Ext.getCmp("incomeType_term").enable();
			
			cleanCustReceivePanelWithoutGuideID();
			cleanEmpInfo();
		} else if (icType == 245) {
			Ext.getCmp("save").enable();
			Ext.getCmp("num_govtReceive").enable();
			Ext.getCmp("reception_govtReceive").enable();
			Ext.getCmp("attractions_govtReceive").enable();
			Ext.getCmp("invoice_govtReceive").enable();
			Ext.getCmp("settleType_govtReceive").enable();
			Ext.getCmp("aamt_govtReceive").enable();
			Ext.getCmp("notifier_govtReceive").enable();
			Ext.getCmp("source_govtReceive").enable();
			Ext.getCmp("deduct_govtReceive").enable();
			Ext.getCmp("incomeType_fit").enable();
			Ext.getCmp("incomeType_custReceive").enable();
			Ext.getCmp("incomeType_cooperateReceive").enable();
			Ext.getCmp("incomeType_term").enable();
			
			cleanGovtReceivePanelWithoutGuideID();
			cleanEmpInfo();
		} else if (icType == 246) {
			Ext.getCmp("save").enable();
			Ext.getCmp("num_cooperateReceive").enable();
			Ext.getCmp("reception_cooperateReceive").enable();
			Ext.getCmp("attractions_cooperateReceive").enable();
			Ext.getCmp("invoice_cooperateReceive").enable();
			Ext.getCmp("settleType_cooperateReceive").enable();
			Ext.getCmp("aamt_cooperateReceive").enable();
			Ext.getCmp("notifier_cooperateReceive").enable();
			Ext.getCmp("source_cooperateReceive").enable();
			Ext.getCmp("deduct_cooperateReceive").enable();
			Ext.getCmp("incomeType_fit").enable();
			Ext.getCmp("incomeType_custReceive").enable();
			Ext.getCmp("incomeType_govtReceive").enable();
			Ext.getCmp("incomeType_term").enable();
			
			cleanCooperateReceivePanelWithoutGuideID();
			cleanEmpInfo();
		}else if (icType == 209) {
			Ext.getCmp("save").enable();
			Ext.getCmp("num_term").enable();
			Ext.getCmp("attractions_term").enable();
			Ext.getCmp("termName_term").enable();
			Ext.getCmp("noticeunit_term").enable();
			Ext.getCmp("invoice_term").enable();
			Ext.getCmp("ratio_term").enable();
			Ext.getCmp("aamt_term").enable();
			Ext.getCmp("incomeType_fit").enable();
			Ext.getCmp("incomeType_custReceive").enable();
			
			cleanTermPanelWithoutGuideID();
			cleanEmpInfo();
		}
	}
	
	/**
	 * 收入验证
	 */
	function saveValidate(){
		var icType = formPanel.form.findField("incomeType").getGroupValue();
		
		if(icType == 207) {
			if(Ext.getCmp("guideID_fit").getValue()==""){
				Ext.getCmp("guideID_fit").markInvalid("导游编号不能为空");
				return false;
			}
		
			if(Ext.getCmp("num_fit").getValue()==""){
				Ext.getCmp("num_fit").markInvalid("带团人数不能为空");
				return false;
			}
			
			if(Ext.getCmp("attractions_fit").getValue()==""){
				Ext.getCmp("attractions_fit").markInvalid("请选择观光点");
				return false;
			}
			
			if(Ext.getCmp("eamt_fit").getValue()==""){
				Ext.getCmp("eamt_fit").markInvalid("预售金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("samt_fit").getValue()==""){
				Ext.getCmp("samt_fit").markInvalid("应收金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("aamt_fit").getValue()==""){
				Ext.getCmp("aamt_fit").markInvalid("实收金额不能为空");
				return false;
			}		
		} else if(icType == 208) {
			if(Ext.getCmp("guideID_custReceive").getValue()==""){
				Ext.getCmp("guideID_custReceive").markInvalid("导游编号不能为空");
				return false;
			}
		
			if(Ext.getCmp("num_custReceive").getValue()==""){
				Ext.getCmp("num_custReceive").markInvalid("带团人数不能为空");
				return false;
			}
			
			if(Ext.getCmp("attractions_custReceive").getValue()==""){
				Ext.getCmp("attractions_custReceive").markInvalid("请选择观光点");
				return false;
			}
			
			if(Ext.getCmp("eamt_custReceive").getValue()==""){
				Ext.getCmp("eamt_custReceive").markInvalid("预售金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("aamt_custReceive").getValue()==""){
				Ext.getCmp("aamt_custReceive").markInvalid("实收金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("points_custReceive").getValue()==""){
				Ext.getCmp("points_custReceive").markInvalid("点数不能为空");
				return false;
			}
			
			if(Ext.getCmp("deduct_custReceive").getValue()==""){
				Ext.getCmp("deduct_custReceive").markInvalid("导游提成不能为空");
				return false;
			}
		} else if(icType == 245) {
			if(Ext.getCmp("guideID_govtReceive").getValue()==""){
				Ext.getCmp("guideID_govtReceive").markInvalid("导游编号不能为空");
				return false;
			}
		
			if(Ext.getCmp("num_govtReceive").getValue()==""){
				Ext.getCmp("num_govtReceive").markInvalid("带团人数不能为空");
				return false;
			}
			
			if(Ext.getCmp("attractions_govtReceive").getValue()==""){
				Ext.getCmp("attractions_govtReceive").markInvalid("请选择观光点");
				return false;
			}
			
			if(Ext.getCmp("eamt_govtReceive").getValue()==""){
				Ext.getCmp("eamt_govtReceive").markInvalid("预售金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("aamt_govtReceive").getValue()==""){
				Ext.getCmp("aamt_govtReceive").markInvalid("实收金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("points_govtReceive").getValue()==""){
				Ext.getCmp("points_govtReceive").markInvalid("点数不能为空");
				return false;
			}
			
			if(Ext.getCmp("deduct_govtReceive").getValue()==""){
				Ext.getCmp("deduct_govtReceive").markInvalid("导游提成不能为空");
				return false;
			}
		} else if(icType == 246) {
			if(Ext.getCmp("guideID_cooperateReceive").getValue()==""){
				Ext.getCmp("guideID_cooperateReceive").markInvalid("导游编号不能为空");
				return false;
			}
		
			if(Ext.getCmp("num_cooperateReceive").getValue()==""){
				Ext.getCmp("num_cooperateReceive").markInvalid("带团人数不能为空");
				return false;
			}
			
			if(Ext.getCmp("attractions_cooperateReceive").getValue()==""){
				Ext.getCmp("attractions_cooperateReceive").markInvalid("请选择观光点");
				return false;
			}
			
			if(Ext.getCmp("eamt_cooperateReceive").getValue()==""){
				Ext.getCmp("eamt_cooperateReceive").markInvalid("预售金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("aamt_cooperateReceive").getValue()==""){
				Ext.getCmp("aamt_cooperateReceive").markInvalid("实收金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("points_cooperateReceive").getValue()==""){
				Ext.getCmp("points_cooperateReceive").markInvalid("点数不能为空");
				return false;
			}
			
			if(Ext.getCmp("deduct_cooperateReceive").getValue()==""){
				Ext.getCmp("deduct_cooperateReceive").markInvalid("导游提成不能为空");
				return false;
			}
		} else if(icType == 209) {
			if(Ext.getCmp("guideID_term").getValue()==""){
				Ext.getCmp("guideID_term").markInvalid("导游编号不能为空");
				return false;
			}
		
			if(Ext.getCmp("num_term").getValue()==""){
				Ext.getCmp("num_term").markInvalid("带团人数不能为空");
				return false;
			}
			
			if(Ext.getCmp("attractions_term").getValue()==""){
				Ext.getCmp("attractions_term").markInvalid("请选择观光点");
				return false;
			}
			
			if(Ext.getCmp("eamt_term").getValue()==""){
				Ext.getCmp("eamt_term").markInvalid("预售金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("samt_term").getValue()==""){
				Ext.getCmp("samt_term").markInvalid("应收金额不能为空");
				return false;
			}
			
			if(Ext.getCmp("aamt_term").getValue()==""){
				Ext.getCmp("aamt_term").markInvalid("实收金额不能为空");
				return false;
			}		
		}

		return true;
	}
	
	/**
	 * 判断是否是销时状态
	 */
	function saveValidateForEndTime(){
		var icType = formPanel.form.findField("incomeType").getGroupValue();
		
		if(icType == 207) {
			if(Ext.getCmp("guideID_fit").getValue()==""){
				return false;
			}
		
			if(Ext.getCmp("num_fit").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("attractions_fit").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("eamt_fit").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("samt_fit").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("aamt_fit").getValue()==""){
				return false;
			}		
		} else if(icType == 208) {
			if(Ext.getCmp("guideID_custReceive").getValue()==""){
				return false;
			}
		
			if(Ext.getCmp("num_custReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("attractions_custReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("eamt_custReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("aamt_custReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("points_custReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("deduct_custReceive").getValue()==""){
				return false;
			}
		} else if(icType == 245) {
			if(Ext.getCmp("guideID_govtReceive").getValue()==""){
				return false;
			}
		
			if(Ext.getCmp("num_govtReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("attractions_govtReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("aamt_govtReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("deduct_govtReceive").getValue()==""){
				return false;
			}
		} else if(icType == 246) {
			if(Ext.getCmp("guideID_cooperateReceive").getValue()==""){
				return false;
			}
		
			if(Ext.getCmp("num_cooperateReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("attractions_cooperateReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("aamt_cooperateReceive").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("deduct_cooperateReceive").getValue()==""){
				return false;
			}
		} else if(icType == 209) {
			if(Ext.getCmp("guideID_term").getValue()==""){
				return false;
			}
		
			if(Ext.getCmp("num_term").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("attractions_term").getValue()==""){
				return false;
			}
			
			if(Ext.getCmp("aamt_term").getValue()==""){
				return false;
			}		
		}

		return true;
	}
	
	/**
	 * 清空散客
	 */
	function cleanFitPanelWithoutGuideID() {
		Ext.getCmp("eamt_fit").setValue("");
		Ext.getCmp("num_fit").setValue("");
		Ext.getCmp("samt_fit").setValue("");
		Ext.getCmp("ratio_fit").setValue("");
		Ext.getCmp("aamt_fit").setValue("");
		Ext.getCmp("remark_fit").setValue("");
		Ext.getCmp("attractions_fit").setValue("");
		Ext.getCmp("samt_big").setText("应收金额：");
	}
	
	function cleanFitPanel() {
		Ext.getCmp("guideID_fit").setValue("");
		cleanFitPanelWithoutGuideID();	
	}
	
	/**
	 * 清空局务接待
	 */
	function cleanCustReceivePanelWithoutGuideID() {
		Ext.getCmp("settleType_custReceive").setValue("");
		Ext.getCmp("eamt_custReceive").setValue("");
		Ext.getCmp("num_custReceive").setValue("");
		Ext.getCmp("aamt_custReceive").setValue("");
		Ext.getCmp("reception_custReceive").setValue("");
		Ext.getCmp("notifier_custReceive").setValue("");
		Ext.getCmp("attractions_custReceive").setValue("");
		Ext.getCmp("source_custReceive").setValue("");
		Ext.getCmp("remark_custReceive").setValue("");
		Ext.getCmp("deduct_custReceive").setValue("");
		Ext.getCmp("samt_big").setText("应收金额：");
	}
	
	function cleanCustReceivePanel() {
		Ext.getCmp("guideID_custReceive").setValue("");
		cleanCustReceivePanelWithoutGuideID();
	}
	
	/**
	 * 清空政府接待
	 */
	function cleanGovtReceivePanelWithoutGuideID() {
		Ext.getCmp("settleType_govtReceive").setValue("");
		Ext.getCmp("eamt_govtReceive").setValue("");
		Ext.getCmp("num_govtReceive").setValue("");
		Ext.getCmp("aamt_govtReceive").setValue("");
		Ext.getCmp("reception_govtReceive").setValue("");
		Ext.getCmp("notifier_govtReceive").setValue("");
		Ext.getCmp("attractions_govtReceive").setValue("");
		Ext.getCmp("source_govtReceive").setValue("");
		Ext.getCmp("remark_govtReceive").setValue("");
		Ext.getCmp("deduct_govtReceive").setValue("");
		Ext.getCmp("samt_big").setText("应收金额：");
	}
	
	function cleanGovtReceivePanel() {
		Ext.getCmp("guideID_govtReceive").setValue("");
		cleanGovtReceivePanelWithoutGuideID();
	}
	
	/**
	 * 清空协作单位
	 */
	function cleanCooperateReceivePanelWithoutGuideID() {
		Ext.getCmp("settleType_cooperateReceive").setValue("");
		Ext.getCmp("eamt_cooperateReceive").setValue("");
		Ext.getCmp("num_cooperateReceive").setValue("");
		Ext.getCmp("aamt_cooperateReceive").setValue("");
		Ext.getCmp("reception_cooperateReceive").setValue("");
		Ext.getCmp("notifier_cooperateReceive").setValue("");
		Ext.getCmp("attractions_cooperateReceive").setValue("");
		Ext.getCmp("source_cooperateReceive").setValue("");
		Ext.getCmp("remark_cooperateReceive").setValue("");
		Ext.getCmp("deduct_cooperateReceive").setValue("");
		Ext.getCmp("samt_big").setText("应收金额：");
	}
	
	function cleanCooperateReceivePanel() {
		Ext.getCmp("guideID_cooperateReceive").setValue("");
		cleanCooperateReceivePanelWithoutGuideID();
	}
	
	/**
	 * 清空团队
	 */
	function cleanTermPanelWithoutGuideID() {
		Ext.getCmp("eamt_term").setValue("");
		Ext.getCmp("num_term").setValue("");
		Ext.getCmp("ratio_term").setValue("");
		Ext.getCmp("samt_term").setValue("");
		Ext.getCmp("attractions_term").setValue("");
		Ext.getCmp("aamt_term").setValue("");
		Ext.getCmp("termName_term").setValue("");
		Ext.getCmp("noticeunit_term").setValue("");
		Ext.getCmp("remark_term").setValue("");
		Ext.getCmp("samt_big").setText("应收金额：");
	}
	
	function cleanTermPanel() {
		Ext.getCmp("guideID_term").setValue("");
		cleanTermPanelWithoutGuideID();
	}
	
	/**
	 * 清空导游信息
	 */
	function cleanEmpInfo() {
		Ext.getCmp("eName_show").setText("姓名：");
		Ext.getCmp("age_show").setText("年龄：");
		Ext.getCmp("sex_show").setText("性别：");
		Ext.getCmp("workID_show").setText("工号：");
		Ext.getCmp("term_show").setText("组别：");
		Ext.getCmp("tel_show").setText("联系方式：");
		Ext.getCmp("eLevel_show").setText("英语等级：");
		Ext.getCmp("mLevel_show").setText("普通话等级：");
		Ext.getCmp("starLevel_show").setText("员工星级：");
		Ext.getCmp("cCard_show").setText("导游证情况：");
		Ext.get('imageBrowse').dom.src = nonImage;
	}
	
	/**
	 * 获取员工等级
	 */
	function getEmpStarLevel(guideID) {
		var obj = new Object();
		obj.guideID = guideID;
		
		var url=clsUrl+'&methodName=getEmpStarLevel&paramCount=0'
		
    	httpReq=null;
		httpReq = getXMLHttpRequest();
    	httpReq.onreadystatechange = onGetEmpStarLevelRtn;
		httpReq.open("POST",url, false);
		httpReq.send(Ext.util.JSON.encode(obj));
	}
	
	function onGetEmpStarLevelRtn() {
		if(httpReq.readyState == 4){
		   	if(httpReq.status == 200){
		   		if(httpReq.responseText != "数据库操作失败"){
		   			starLevel = httpReq.responseText;
		   			
					httpReq=null;
		   		}else{
		   			Ext.Msg.show({   
		    	   		title : '错误提示',
		    	   		width:200,
		   				msg :httpReq.responseText,  
			       		buttons : Ext.Msg.OK,   
			       		icon : Ext.Msg.ERROR   
		   			});  
		   			httpReq=null;
		   		}
		   	}
		}
	}
	
	/**
	 * 设置销时时间及导游提成
	 */
	function setEndTimeAndDeduct(record) {
		/*
		 * 设置销时时间
		 */
		var date = new Date();
		var year = date.getYear();
		var month = date.getMonth()+1;
		var day = date.getDate();
		var hours = date.getHours();
		var minutes = date.getMinutes();
		var seconds = date.getSeconds();
		
		var timeValue1 = ((hours < 10) ? "0" : "") + hours+"";
		timeValue1 += ((minutes < 10) ? ":0" : ":") + minutes+"";
		timeValue1 += ((seconds < 10) ? ":0" : ":") + seconds+"";
		
		var timeValue2 = year;
		timeValue2 += ((month < 10) ? "-0" : "-") + month+"";
		timeValue2 += ((day < 10) ? "-0" : "-") + day+"";
		
		var now = timeValue2+" "+timeValue1
		
		Ext.getCmp("endTime").setValue(now);
		
		/*
		 * 设置导游提成
		 */
		
		// 观光点个数
		attractionsNums = record.data.ATTRACTIONS.split(",").length;
		
		// 获取starLevel
		getEmpStarLevel(record.data.GUIDEID);
		
		// 收入类型
		incomeType =  record.data.INCOMETYPE;
		
		// 导游提成
		var deduct = "";
		
		// 散客及中心业务单位收入
		if(incomeType==207 || incomeType==209) {
			// 应收金额
			var samt = record.data.SAMT;
					
			// 一星员工
			if(starLevel == 26) {
				if(attractionsNums == 1) {
					deduct = samt*0.35;
				} else if(attractionsNums == 2) {
					deduct = samt*0.4;
				} else if(attractionsNums >= 3) {
					deduct = samt*0.45;
				}
			// 二星员工
			} else if(starLevel == 27) {
				if(attractionsNums == 1) {
					deduct = samt*0.4;
				} else if(attractionsNums == 2) {
					deduct = samt*0.45;
				} else if(attractionsNums >= 3) {
					deduct = samt*0.5;
				}
			// 三星员工
			} else if(starLevel == 28) {
				if(attractionsNums == 1) {
					deduct = samt*0.45;
				} else if(attractionsNums == 2) {
					deduct = samt*0.5;
				} else if(attractionsNums >= 3) {
					deduct = samt*0.55;
				}
			// 兼职员工
			} else {
				deduct = samt*0.35;
			}
		// 协作单位
		} else if(incomeType==246) {
			// 实收金额
			var aamt = record.data.AAMT;
					
			// 一星员工
			if(starLevel == 26) {
				if(attractionsNums == 1) {
					deduct = aamt*0.35;
				} else if(attractionsNums == 2) {
					deduct = aamt*0.4;
				} else if(attractionsNums >= 3) {
					deduct = aamt*0.45;
				}
			// 二星员工
			} else if(starLevel == 27) {
				if(attractionsNums == 1) {
					deduct = aamt*0.4;
				} else if(attractionsNums == 2) {
					deduct = aamt*0.45;
				} else if(attractionsNums >= 3) {
					deduct = aamt*0.5;
				}
			// 三星员工
			} else if(starLevel == 28) {
				if(attractionsNums == 1) {
					deduct = aamt*0.45;
				} else if(attractionsNums == 2) {
					deduct = aamt*0.5;
				} else if(attractionsNums >= 3) {
					deduct = aamt*0.55;
				}
			// 兼职员工
			} else {
				deduct = aamt*0.35;
			}
		// 局务接待及政府接待
		} else {
			deduct = record.data.DEDUCT;
		} 
		
		var num = new Number(deduct);

		Ext.getCmp("deduct").setValue(num.toFixed(2));
	}
	
	/**
	 * 定义拖动时样式
	 */
	function change(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '</span>';
        }
        return val;
    }
    
    /**
     * 定义拖动时样式
     */
    function pctChange(val){
        if(val > 0){
            return '<span style="color:green;">' + val + '%</span>';
        }else if(val < 0){
            return '<span style="color:red;">' + val + '%</span>';
        }
        return val;

    }
	
	store.load();
	sortStore.load();
});